using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using DataAccess;
using Entity; 

namespace Business
{
    public class bBill
    {
        public static int insertBill(eBill bill)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter pr = new SqlParameter("@AccountID", SqlDbType.VarChar);
            pr.Value = bill.AccountID;
            paramList.Add(pr);

            pr = new SqlParameter("@Money", SqlDbType.Float);
            pr.Value = bill.Money;
            paramList.Add(pr);

            pr = new SqlParameter("@Date", SqlDbType.DateTime);
            pr.Value = bill.Date    ;
            paramList.Add(pr);

            pr = new SqlParameter("@Status", SqlDbType.Int);
            pr.Value =0;
            paramList.Add(pr);

            pr = new SqlParameter("@employeeID", SqlDbType.Int);
            pr.Value =bill.employeeID;
            paramList.Add(pr);

            int r = dbh.ExecuteNonQuery("insertBill", CommandType.StoredProcedure, paramList);
            dbh.CloseConnection();
            return r;
        }
        public static int updateStatusBill(int billID, int status)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter pr = new SqlParameter("@BillID", SqlDbType.Int);
            pr.Value = billID;
            paramList.Add(pr);

            pr = new SqlParameter("@Status", SqlDbType.Int);
            pr.Value = status;
            paramList.Add(pr);

            int r = dbh.ExecuteNonQuery("updateStatusBill", CommandType.StoredProcedure, paramList);
            dbh.CloseConnection();
            return r;
        }

        public static int deleteBill(int BillID)
        {
            DBHelper dbh = new DBHelper();

            IList<SqlParameter> paramList = new List<SqlParameter>();
            SqlParameter pr = new SqlParameter("@BillID", SqlDbType.VarChar);
            pr.Value = BillID;
            paramList.Add(pr);

            int r = dbh.ExecuteNonQuery("deleteBill", CommandType.StoredProcedure, paramList);
            dbh.CloseConnection();
            return r;
        }
    }
}
